import { getHeaderCategory } from '@/api/home'

// 存储电商菜单数据
export default {
  namespaced: true,
  state: {
    // 菜单分类数据
    cateList: []
  },
  mutations: {
    /**
     *
     * @param {*} state 获取变量对象
     * @param {*} cateList 调用时传入的菜单数据
     */
    updatecateList (state, cateList) {
      state.cateList = cateList
    }
  },
  actions: {
    // 获取导航菜单数据
    async getCateList ({ commit }) {
      const { result } = await getHeaderCategory()
      // console.log(result)
      commit('updatecateList', result)
    }
  }
}
